﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XCommunity.Frames;
using XCommunity.Documents;

namespace XCommunity.Views
{
  public class PublishedDocumentView : ViewObject
  {

    public PublishedDocumentView( ViewService service, PublishedDocument document )
      : base( service )
    {
      PublishedDocument = document;
    }


    protected PublishedDocument PublishedDocument
    {
      get;
      private set;
    }


    public int DocumentId
    {
      get { return PublishedDocument.DocumentId; }
    }


    public DateTime PublishDate
    {
      get { return PublishedDocument.PublishDate; }
    }


    private Document _document;

    public Document Document
    {
      get
      {
        if ( _document == null )
          _document = PublishedDocument.GetDocument();

        return _document;
      }
    }


    public string Author
    {
      get { return DocumentMeta.Author; }
    }


    public string DocumentTitle
    {
      get { return DocumentMeta.Caption; }
    }


    public DocumentMeta DocumentMeta
    {
      get { return Document.Meta; }
    }



    public override object BaseObject
    {
      get { return PublishedDocument; }
    }
  }
}
